package com.ruge.spring.cloud.gateway.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 嘿丷如歌
 * @version V1.0
 * @Description:
 * @date 2021/4/26 20:05
 */
@Configuration
@ConfigurationProperties(prefix = "config")
public class AppConfig {

    private List<String> appkeyCheckWhiteList;

    private List<String> userTokenCheckWhiteList;

    private List<String> adminTokenCheckService;

    private List<String> adminTokenCheckWhiteList;

    private Map<String, List<String>> nonStandardPath;

    public List<String> getAppkeyCheckWhiteList() {
        if (appkeyCheckWhiteList == null) {
            appkeyCheckWhiteList = new ArrayList<>();
        }
        return appkeyCheckWhiteList;
    }

    public void setAppkeyCheckWhiteList(List<String> appkeyCheckWhiteList) {
        this.appkeyCheckWhiteList = appkeyCheckWhiteList;
    }

    public List<String> getUserTokenCheckWhiteList() {
        if (userTokenCheckWhiteList == null) {
            userTokenCheckWhiteList = new ArrayList<>();
        }
        return userTokenCheckWhiteList;
    }

    public void setUserTokenCheckWhiteList(List<String> userTokenCheckWhiteList) {
        this.userTokenCheckWhiteList = userTokenCheckWhiteList;
    }

    public List<String> getAdminTokenCheckServices() {
        if (adminTokenCheckService == null) {
            adminTokenCheckService = new ArrayList<>();
        }
        return adminTokenCheckService;
    }

    public void setAdminTokenCheckServices(List<String> adminTokenCheckService) {

        this.adminTokenCheckService = adminTokenCheckService;
    }

    public List<String> getAdminTokenCheckWhiteList() {
        if (adminTokenCheckWhiteList == null) {
            adminTokenCheckWhiteList = new ArrayList<>();
        }
        return adminTokenCheckWhiteList;
    }

    public void setAdminTokenCheckWhiteList(List<String> adminTokenCheckWhiteList) {
        this.adminTokenCheckWhiteList = adminTokenCheckWhiteList;
    }

    public Map<String, List<String>> getNonStandardPath() {
        if (adminTokenCheckWhiteList == null) {
            Map<String, List<String>> pathMap = new HashMap<>(4);
            pathMap.put("admin", new ArrayList<>());
            pathMap.put("public", new ArrayList<>());
            pathMap.put("internal", new ArrayList<>());
            pathMap.put("inpublic", new ArrayList<>());
            nonStandardPath = pathMap;
        }
        return nonStandardPath;
    }

    public void setNonStandardPath(Map<String, List<String>> nonStandardPath) {
        this.nonStandardPath = nonStandardPath;
    }

    public List<String> getAdminTokenCheckService() {
        return adminTokenCheckService;
    }

    public void setAdminTokenCheckService(List<String> adminTokenCheckService) {
        this.adminTokenCheckService = adminTokenCheckService;
    }
}
